import React, {Component} from 'react';
import {connect} from "react-redux";
import {Table, Tooltip} from 'antd';

class VipLogList extends Component {
    constructor(props) {
        super(props);
        this.state = {
            data: [],
            pageNum: 1,
            pageSize: 10,
            current: 1
        }

        this.columns = [
            {
                title: 'id',
                dataIndex: 'id',

            },
            {
                title: '昵称',
                dataIndex: 'nickName',

            },
            {
                title: '姓名',
                dataIndex: 'name',

            },
            {
                title: '会员',
                dataIndex: 'unit',

            },
            {
                title: '用户id',
                dataIndex: 'mid',

            },
            {
                title: '支付类型',
                render: (_, record) => {
                    return (
                        <div>
                            {record.payMethod === 0 ? <div style={{color: "blue"}}>余额</div> : record.payMethod === 1 ?
                                <div>微信</div> :record.payMethod === 2 ? <div style={{color: "red"}}>支付宝</div> :
                                    record.payMethod === -1 ? <div style={{color: "gray"}}>苹果</div> :''}
                        </div>
                    );
                }
            },

            {
                title: '时间',
                dataIndex: 'addTime',

            },

            {
                title: '订单号',
                dataIndex: 'rechargeSlipNum',

            }

        ];
    }

    componentDidMount() {
        this.init();
    }


    init = () => {
        this.props.vipLogList({page: this.state.pageNum, size: this.state.pageSize})
    }

    query = (current, pageSize) => {
        this.setState({current})
        let newValues = this.props.newValues;
        newValues.page = current
        newValues.size=this.state.pageSize
        this.props.vipLogList(newValues)
    }


    render() {
        const {vipLogsData, userLoading} = this.props;
        const pagination = {
            current: vipLogsData.current,//当前页
            total: vipLogsData.total,//总条数
            pageSize: vipLogsData.size,//页大小
            onChange: this.query,
            showQuickJumper: true,//快速跳转
            showSizeChanger: false//大于50时显示pageSize切换器
        };
        return (
            <div>
                <Table columns={this.columns} loading={userLoading} dataSource={vipLogsData.records}
                       rowKey={record => record.id} pagination={pagination}/>

            </div>

        );
    }
}


const mapState = state => ({
    ...state.vip
});

const mapDispatch = dispatch => ({
    ...dispatch.vip

})

export default connect(mapState, mapDispatch)(VipLogList);